#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 2e5 + 10;

int v[N],t[N],col[N],n,m;
ll s[2];
bool fl;
vec G[N];

void dfs(int x,int c) {
	col[x] = c;
	for(auto y : G[x]) {
		if(col[y] == -1) dfs(y,c ^ 1);
		else if(col[y] == col[x]) fl = 0;
	}
}

void solve() {
	n = in,m = in; for(int i = 1;i <= n;i++) col[i] = -1; for(int i = 1;i <= n;i++) v[i] = in; for(int i = 1;i <= n;i++) t[i] = in;
	for(int i = 1;i <= n;i++) G[i].clear(); for(int i = 1,u,v;i <= m;i++) u = in,v = in,G[u].pb(v),G[v].pb(u);
	fl = 1; for(int i = 1;i <= n;i++) if(col[i] == -1) dfs(i,1);
	ll ts = 0; for(int i = 1;i <= n;i++) ts += v[i] - t[i]; if(ts & 1) return puts("NO"),void();
	if(fl == 0) puts("YES");
	else {
		s[0] = s[1] = 0; for(int i = 1;i <= n;i++) s[col[i]] += v[i] - t[i];
		puts(s[0] == s[1] ? "YES" : "NO");
	}
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	for(int T = in;T;T--) solve();
	return 0;
}
